package com.fpx.metadata.config;

import com.fpx.metadata.job.KettleJob;
import com.fpx.metadata.job.MysqlJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 
 * @author Administrator
 *
 */
//@Configuration
public class JobConfig {

    @Bean
    public JobDetail mysqlJobDetail() {
        return JobBuilder.newJob(MysqlJob.class).withIdentity("MysqlJob")
                                .storeDurably().build();
    }

    @Bean
    public Trigger mysqlJobTrigger() {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("* 0/5 * * * ?");
        return TriggerBuilder.newTrigger().forJob(mysqlJobDetail())
                .withIdentity("uploadTask")
                .withSchedule(scheduleBuilder)
                .build();
    }

    @Bean
    public JobDetail kettleJobDetail() {
        return JobBuilder.newJob(KettleJob.class).withIdentity("KettleJob")
                                .storeDurably().build();
    }

    @Bean
    public Trigger kettleJobTrigger() {
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("* 0/5 * * * ?");
        return TriggerBuilder.newTrigger().forJob(kettleJobDetail())
                .withIdentity("kettleJob")
                .withSchedule(scheduleBuilder)
                .build();
    }

}